<?php defined('BASEPATH') or exit('No direct script access allowed');

/**
 * Theme Plugin
 *
 * Load partials and access data
 *
 * @author  PyroCMS Dev Team
 * @package PyroCMS\Core\Plugins
 Toolbar cho Admin
 */

class Plugin_Toolbar extends Plugin
{

	public $version = '1.1.0';
	public $name = array(
		'en' => 'Toolbar',
	);
	public $description = array(
		'en' => 'Toolbar.'
	);

	public function _self_doc()
	{
		$info = array();
			
		return $info;
	}


	public function actions()
	{
		$html = "";
		$str      = $this->attribute('act');
		if($str){
			$actions = explode('+',$str);
			$list_action = array();
			foreach( $actions as $ac ){
				$obj = explode('|',$ac);
				$item = array(
							'class'=>trim($obj[0]),
							'action'=>trim($obj[1]),
							'title'=>trim($obj[2])
						);
				$list_action[] = $item;
			}
					foreach($list_action as $item){
				$html .= "<li class=\"".$item['class']."\"> <a href=\"".$item['action']."\"> <i class=\"".$item['class']."\"></i>".$item['title']."</a></li>";
			}
		
		}
		return $html;
		
	}
	
	public function language(){
		$html = "";
		$this->load->config('language');
		$this->lang_array = $this->config->item('supported_languages');
		$lang = $this->session->userdata('ss_lang');
		if(count($this->lang_array)>1){
			$html .= '<div class="title inner">'.lang('global:language').'</div>';
			$lang_array_select = array_for_select($this->lang_array,'id','name');
			$options = 'class = "chzn-select-deselect language" style="width:100%;" ';
			$html .= form_open();
			$html .= form_dropdown('language',$lang_array_select,$lang['id'],$options);
			$html .= form_close();
		}
		return $html;
	}

	

}
